package com.candy.candymessage.business.controller;

import com.candy.candycommon.utils.ResultBean;
import com.candy.candymessage.business.service.MsgSendService;
import com.candy.candymessagerpc.bean.Message;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author suYanLong
 * @date 2023年05月18日 14:24
 */
@Slf4j
@RestController
@RequestMapping("message")
@AllArgsConstructor
public class MsgSendController {

    private final MsgSendService msgSendService;

    public String sendMsg() {
        return "true";
    }

    @GetMapping("exception")
    public String exception() {
        int i = 1 / 0;
        return "true";
    }

    @PostMapping("send")
    ResultBean send(@RequestBody Message message) {
        return ResultBean.ok(msgSendService.sendMsgNotice(message.getType(), message.getMsg()));
    }

}
